home *** CD-ROM | disk | FTP | other *** search
/ WINMX Assorted Textfiles / Ebooks.tar / Text - Tech - Networking - The HTTP Protocol.txt < prev    next >
Text File  |  2003-07-22  |  6KB  |  152 lines

  1.  
  2.  
  3.  
  4.   The HTTP Protocol
  5.  
  6.   @ Articles -> Networking     Aug 28 2002 - 09:44 EST
  7.  
  8.   cereal writes: http (Hypertext transfer Protocol) is the protocol that allows Web servers and browsers to exchange data over the web. It is a request/response protocol, meaning the server waits for and responds to client requests. HTTP does not
  9.   maintain a connection whit the client. HTTP predominantly uses reliable TCP connections, most often on port 80.
  10.  
  11.   These client/server transactions can be divided into four basic steps:
  12.   1, the browser connects to the server
  13.  
  14.   2, the browser requests a document from the server
  15.   3, the server responds to the browser
  16.   4, the connection is dropped
  17.   Http is a stateless protocol in that it dos not maintain any information about the connection.
  18.  
  19.   1. HTTP 1.1,
  20.  
  21.   To make communication possible between the server and the client, the HTTP-protocol establishes a language of the web that is made up of request and response messages.
  22.  
  23.   1.1 Client Request,
  24.   A client request contains the following information:
  25.   1, Request Method
  26.   2, Request Header
  27.  
  28.   3, Request Data
  29.   The Request Method is the program to be applied to the specified URL or Web page.
  30.   Below are the available methods shown.
  31.  
  32.   Method Description
  33.  
  34.   GET Requests the specified document
  35.   HEAD Requests only the document head
  36.   POST Request that the server accept the specified document as an executable and pass it some information
  37.   PUT Replace the contents of the specified document with data from the client.
  38.  
  39.   DELETE Request that the server delete the specified page
  40.   OPTIONS Allows the client to see the capabilities or requirements of the server
  41.   TRACE Used for testing, allows the client to se how the message was retrieved
  42.  
  43.   The Header information is optional, and is used to provide the server whit additional information about the client.
  44.  
  45.   Below are the available headers shown.
  46.  
  47.   Header Description
  48.   Accept The type of data the client will accept
  49.   Authorization Includes authentication information like username and password
  50.  
  51.   User-Agent The type of client software being used
  52.   Referer The web page from which the user is coming. (and yes it is spelled this way)
  53.  
  54.   If the method used requires data from the client (example: POST) the client follows the header with data. Otherwise the client waits for a response from the server.
  55.  
  56.   1.2 Server Response,
  57.   Server response also contains several key items:
  58.  
  59.   1, Status code
  60.   2, Response Header
  61.   3, Response Data
  62.  
  63.   HTTP defines several groups of status codes to communicate back to the browser
  64.  
  65.  
  66.   Code What example
  67.   1xx Information 100 = Continue
  68.   2xx Successful 202 = Accepted
  69.   3xx Redirection 305 = Use Proxy
  70.  
  71.   4xx Client Error 404 = Not found 403 = Forbidden
  72.   5xx Server Error 500 = Internal Server Error
  73.  
  74.   Response headers provide the client with information about the server and/or requested document.
  75.  
  76.   Method Description
  77.  
  78.   Server Information about the Web server
  79.   Date The current date/time
  80.   Last modified The date/time that the requested document was last modified
  81.   Expires The date/time that the requested document expires.
  82.  
  83.   Content-type The MIME Type of data
  84.   Content-length The size (in bytes) of data
  85.   WWW-authenticate Used to tell the client the information that is required for authentication
  86.  
  87.   If the client has requested data, the data will follow. Otherwise the server closes the connection.
  88.  
  89.   2. MIME and the web,
  90.  
  91.   Multipurpose Internet Mail Extension (MIME) are used on the Web to specify the classification of a chunk of data (example : a file of a web page). Mime allows you to send data in formats other than plain text. Thanks to MIME, you can send and receive
  92.   Web pages that contain non-ASCII data such as sound, video, à
  93.   When Web browsers and servers communicate, they discuss MIME types. The browser can send information about the MIME types it can accept in the request header. The server tells the client the MIME type of data it is about to send.
  94.  
  95.   Mime Type Description
  96.  
  97.   text/plain Plain ASCII text
  98.   text/html HTML text
  99.   image/gif GIFF image
  100.   image/jpeg JPEG image
  101.  
  102.   application/msword Microsoft Word
  103.   video/mpeg MPEG video
  104.   audio/wave Wave audio
  105.   application/x-tar Tar compressed data
  106.  
  107.   3. Sample HTTP Communication,
  108.  
  109.   3.1 The request,
  110.  
  111.   In this example, the browser is requesting the document identified by the URL http://www.example.com/index.html. All request end whit a blank line, as shown here:
  112.  
  113.   GET /index.html HTTP/1.1
  114.   Accept: text/plain
  115.   Accept: text/html
  116.  
  117.   User-agent: Mozilla/4.5 (winNT)
  118.   (blank line)
  119.  
  120.   The browser is using the GET method to request the document /index.html. The browser indicates that it will only accept plain text and HTML data, and that it is using the Mozilla/4.5 engine.
  121.  
  122.   3.2 The Response,
  123.   The server responds whit a status code, some header information (followed by a blank line), and if applicable, the requested data.
  124.  
  125.  
  126.   HTTP/1.1 200 OK
  127.   Date Sunday, 25-jul-02 12:18:03 GMT
  128.   Server: Apache/1.3.6
  129.   MIME-version: 1.0
  130.  
  131.   Content-type: text/html
  132.   Last-modified: thursday, 20-jun-02 20:43:56 GMT
  133.   Content-length: 1423
  134.   (blank line)
  135.  
  136.   (and then the HTML code)
  137.  
  138.  
  139.   The next example assumes the document was not found:
  140.  
  141.   HTTP/1.1 404 NOT FOUND
  142.   Date Sunday, 25-jul-02 12:18:03 GMT
  143.  
  144.   Server: Apache/1.3.6
  145.  
  146.   well thats it, i think, would not know what to write more about it.
  147.  
  148.   ~Cereal
  149.  
  150.  
  151.   (c) New Order / http://neworder.box.sk/
  152.